"""empty message

Revision ID: 69b1deed0316
Revises: f7671d2a7bff
Create Date: 2025-08-01 16:59:24.917561

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '69b1deed0316'
down_revision: Union[str, None] = 'f7671d2a7bff'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('collection_marketplace',
    sa.Column('id', sa.String(length=24), nullable=False),
    sa.Column('collection_id', sa.String(length=24), nullable=False),
    sa.Column('status', sa.String(length=20), nullable=False),
    sa.Column('gmt_created', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_updated', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_deleted', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('collection_id', name='uq_collection_marketplace_collection')
    )
    op.create_index('idx_collection_marketplace_collection_id', 'collection_marketplace', ['collection_id'], unique=False)
    op.create_index('idx_collection_marketplace_gmt_deleted', 'collection_marketplace', ['gmt_deleted'], unique=False)
    op.create_index('idx_collection_marketplace_list', 'collection_marketplace', ['status', 'gmt_created'], unique=False)
    op.create_index('idx_collection_marketplace_status', 'collection_marketplace', ['status'], unique=False)
    op.create_table('user_collection_subscription',
    sa.Column('id', sa.String(length=24), nullable=False),
    sa.Column('user_id', sa.String(length=24), nullable=False),
    sa.Column('collection_marketplace_id', sa.String(length=24), nullable=False),
    sa.Column('gmt_subscribed', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_deleted', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'collection_marketplace_id', 'gmt_deleted', name='idx_user_marketplace_history_unique')
    )
    op.create_index('idx_user_subscription_gmt_deleted', 'user_collection_subscription', ['gmt_deleted'], unique=False)
    op.create_index('idx_user_subscription_marketplace', 'user_collection_subscription', ['collection_marketplace_id'], unique=False)
    op.create_index('idx_user_subscription_user', 'user_collection_subscription', ['user_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('idx_user_subscription_user', table_name='user_collection_subscription')
    op.drop_index('idx_user_subscription_marketplace', table_name='user_collection_subscription')
    op.drop_index('idx_user_subscription_gmt_deleted', table_name='user_collection_subscription')
    op.drop_table('user_collection_subscription')
    op.drop_index('idx_collection_marketplace_status', table_name='collection_marketplace')
    op.drop_index('idx_collection_marketplace_list', table_name='collection_marketplace')
    op.drop_index('idx_collection_marketplace_gmt_deleted', table_name='collection_marketplace')
    op.drop_index('idx_collection_marketplace_collection_id', table_name='collection_marketplace')
    op.drop_table('collection_marketplace')
    # ### end Alembic commands ###
